package com.ymatou.iapi.exp.testcase;

import java.math.BigDecimal;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.common.collect.Lists;
import com.ymatou.iapi.exp.parameter.ParamExt;
import com.ymatou.iapi.exp.parameter.SubscibeCallbackBean;
import com.ymatou.iapi.exp.service.AddCoinFromTradingCallback;
import com.ymatou.iapi.optrade.parameter.enums.BizTypeEnum;
import com.ymatou.iapi.optrade.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.optrade.parameter.vo.OrderItemVo;
import com.ymatou.iapi.optrade.resp.TradingServiceResp;
import com.ymatou.iapi.synctrade.service.TradingSyncService;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymttest.business.service.AccountCallServiceV2;
import com.ymttest.business.service.ExpCallService;
import com.ymttest.business.service.PayGateWayCallService;
import com.ymttest.business.service.YMTTrading.TradingCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceHunterOrderCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceOrderCallService;
import com.ymttest.database.model.UserCoinRecord;
import com.ymttest.database.sqlwapper.ExpWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;

/**
 * 交易服务事件回调 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_AddCoinFromTradingCallback {
	private static SubscibeCallbackBean SubscibeCallbackBean;
	private static AddCoinFromTradingCallback AddCoinFromTradingCallback;
	private static ExpWapper ew;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("交易服务事件回调");
	}

	@Before
	public void caseUp() {
		SubscibeCallbackBean = new SubscibeCallbackBean();
		AddCoinFromTradingCallback = new AddCoinFromTradingCallback();
		ew = new ExpWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(AddCoinFromTradingCallback.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void verifyDB(SubscibeCallbackBean subscibeCallbackBean2) {
		UserCoinRecord coinrord = ew.selectUserCoinRecord(subscibeCallbackBean2.getBuyerId(), null, SubscibeCallbackBean.getOrderId(), null).get(0);
		Logger.verifyEquals(SubscibeCallbackBean.getOrderId(), coinrord.getBizNo(), "验证BizNo");
		if (SubscibeCallbackBean.getParamExt().getBizCode().equals("100102")) {
			// 收货加金币
			Logger.verifyEquals("200102", coinrord.getBizCode().toString(), "验证BizCode");
			int coin = Double.valueOf((Double.valueOf(SubscibeCallbackBean.getParamExt().getTotalPrice()) * 0.1)).intValue();
			Logger.verifyEquals(coin, Double.valueOf(coinrord.getCurCoin()).intValue(), "验证CurCoin");
			Logger.verifyEquals(coin, Double.valueOf(coinrord.getTotalCoin()).intValue(), "验证TotalCoin");
		} else if (SubscibeCallbackBean.getParamExt().getBizCode().equals("100202")) {
			// 退货扣金币
			Logger.verifyEquals("200201", coinrord.getBizCode().toString(), "验证BizCode");

			// getSpecId 存在 部分退款
			if (SubscibeCallbackBean.getParamExt().getSpecId() != null) {
				Logger.verifyEquals(SubscibeCallbackBean.getParamExt().getSpecId(), coinrord.getOriginalNo(), "验证OriginalNo");
				Logger.verifyEquals(Double.valueOf(SubscibeCallbackBean.getParamExt().getPrice()) * -0.1, Double.valueOf(coinrord.getCurCoin()), "验证CurCoin");
				Logger.verifyEquals(Double.valueOf(SubscibeCallbackBean.getParamExt().getPrice()) * -0.1, Double.valueOf(coinrord.getTotalCoin()), "验证TotalCoin");
			} else {
				Logger.verifyEquals(SubscibeCallbackBean.getOrderId(), coinrord.getOriginalNo(), "验证OriginalNo");
				if (SubscibeCallbackBean.getParamExt().getTotalPrice() != null) {
					Logger.verifyEquals(Double.valueOf(SubscibeCallbackBean.getParamExt().getTotalPrice()) * -0.1, Double.valueOf(coinrord.getCurCoin()), "验证CurCoin");
					Logger.verifyEquals(Double.valueOf(SubscibeCallbackBean.getParamExt().getTotalPrice()) * -0.1, Double.valueOf(coinrord.getTotalCoin()), "验证TotalCoin");
				} else {
					Logger.comment("手工验证数据:" + FormatUtil.beanToGSONString(coinrord));
				}
			}
		}

	}

	private void verifyDB(SubscibeCallbackBean subscibeCallbackBean2, int rate) {
		UserCoinRecord coinrord = ew.selectUserCoinRecord(subscibeCallbackBean2.getBuyerId(), null, SubscibeCallbackBean.getOrderId(), null).get(0);
		Logger.verifyEquals(SubscibeCallbackBean.getOrderId(), coinrord.getBizNo(), "验证BizNo");
		if (SubscibeCallbackBean.getParamExt().getBizCode().equals("100102")) {
			// 收货加金币
			Logger.verifyEquals("200102", coinrord.getBizCode().toString(), "验证BizCode");
			int coin = Double.valueOf((Double.valueOf(SubscibeCallbackBean.getParamExt().getTotalPrice()) * 0.1)).intValue();
			Logger.verifyEquals(coin * rate, Double.valueOf(coinrord.getCurCoin()).intValue(), "验证CurCoin");
			Logger.verifyEquals(coin * rate, Double.valueOf(coinrord.getTotalCoin()).intValue(), "验证TotalCoin");
		} else if (SubscibeCallbackBean.getParamExt().getBizCode().equals("100202")) {
			// 退货扣金币
			Logger.verifyEquals("200201", coinrord.getBizCode().toString(), "验证BizCode");

			// getSpecId 存在 部分退款
			if (SubscibeCallbackBean.getParamExt().getSpecId() != null) {
				Logger.verifyEquals(SubscibeCallbackBean.getParamExt().getSpecId(), coinrord.getOriginalNo(), "验证OriginalNo");
				Logger.verifyEquals(Double.valueOf(SubscibeCallbackBean.getParamExt().getPrice()) * -0.1 * rate, Double.valueOf(coinrord.getCurCoin()), "验证CurCoin");
				Logger.verifyEquals(Double.valueOf(SubscibeCallbackBean.getParamExt().getPrice()) * -0.1 * rate, Double.valueOf(coinrord.getTotalCoin()), "验证TotalCoin");
			} else {
				Logger.verifyEquals(SubscibeCallbackBean.getOrderId(), coinrord.getOriginalNo(), "验证OriginalNo");
				if (SubscibeCallbackBean.getParamExt().getTotalPrice() != null) {
					Logger.verifyEquals(Double.valueOf(SubscibeCallbackBean.getParamExt().getTotalPrice()) * -0.1 * rate, Double.valueOf(coinrord.getCurCoin()), "验证CurCoin");
					Logger.verifyEquals(Double.valueOf(SubscibeCallbackBean.getParamExt().getTotalPrice()) * -0.1 * rate, Double.valueOf(coinrord.getTotalCoin()), "验证TotalCoin");
				} else {
					Logger.comment("手工验证数据:" + FormatUtil.beanToGSONString(coinrord));
				}
			}
		}

	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_001() {
		Logger.start(true, "交易服务事件回调成功,确认收货增加金币");
		try {
			int uid = 11;

			ExpCallService.resetCoinAccount(uid);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(TestDataManager.getRandomNum(8));
			SubscibeCallbackBean.setBuyerId(uid);
			SubscibeCallbackBean.setSellerId(111);
			SubscibeCallbackBean.setOrderId(1 + TestDataManager.getRandomNum(8));

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			// UserExp exp = ew.selectuserexp(uid).get(0);
			// Logger.verifyEquals(ParamExt.getTotalPrice(),
			// exp.getExp().toString(), "验证exp");
			// UserExpDetail expd = ew.selectuserexpdetail(uid, null, null,
			// null).get(0);
			// Logger.verifyEquals(ParamExt.getTotalPrice(),
			// expd.getExp().toString(), "验证expdetail");
			// Logger.verifyEquals(SubscibeCallbackBean.getParamExt().getBizCode(),
			// expd.getBizCode().toString(), "验证BizCode");
			// Logger.verifyEquals(SubscibeCallbackBean.getOrderId(),
			// expd.getBizNo(), "验证BizNo");
			// Logger.verifyEquals(SubscibeCallbackBean.getOrderId(),
			// expd.getOriginalNo(), "验证OriginalNo");
			// Logger.verifyEquals(1, expd.getOperateType(),
			// "验证OperateType1增加");
			verifyDB(SubscibeCallbackBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_002() {
		Logger.start(true, "交易服务事件回调成功,取消订单扣除金币");
		try {
			int uid = 912;
			ExpCallService.resetCoinAccount(uid);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(TestDataManager.getRandomNum(8));
			SubscibeCallbackBean.setBuyerId(uid);
			SubscibeCallbackBean.setSellerId(111);
			SubscibeCallbackBean.setOrderId(1 + TestDataManager.getRandomNum(8));

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			Thread.sleep(1000);
			ParamExt.setBizCode("100202");
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_003() {
		Logger.start(true, "交易服务事件回调成功,部分退款扣除金币");
		try {
			int uid = 13;
			ExpCallService.resetCoinAccount(uid);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(TestDataManager.getRandomNum(8));
			SubscibeCallbackBean.setBuyerId(uid);
			SubscibeCallbackBean.setSellerId(111);
			SubscibeCallbackBean.setOrderId("9" + TestDataManager.getRandomNum(8));

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			Thread.sleep(1000);
			ParamExt.setBizCode("100202");
			ParamExt.setPrice("30");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_004() {
		Logger.start(true, "交易服务事件回调成功,多次部分退款扣除金币");
		try {
			// 120-30-40
			int uid = 14;
			ExpCallService.resetCoinAccount(uid);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(TestDataManager.getRandomNum(8));
			SubscibeCallbackBean.setBuyerId(uid);
			SubscibeCallbackBean.setSellerId(111);
			SubscibeCallbackBean.setOrderId(1 + TestDataManager.getRandomNum(8));

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			Thread.sleep(1000);
			ParamExt.setBizCode("100202");
			ParamExt.setPrice("30");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			Thread.sleep(1000);
			ParamExt.setPrice("40");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_005() {
		Logger.start(false, "交易服务事件回调成功,多次部分退款扣除金币最后一次金币数量不足时扣到0");
		try {
			// 120-50 然后消费光金币 再-40
			int uid = 15;
			ExpCallService.accountCoin(uid, 0);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(TestDataManager.getRandomNum(8));
			SubscibeCallbackBean.setBuyerId(uid);
			SubscibeCallbackBean.setSellerId(111);
			SubscibeCallbackBean.setOrderId(1 + TestDataManager.getRandomNum(8));

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			Thread.sleep(1000);
			ParamExt.setBizCode("100202");
			ParamExt.setPrice("50");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			Thread.sleep(2000);
			ExpCallService.accountCoin(uid, 3);
			ParamExt ParamExt2 = new ParamExt();
			ParamExt2.setPrice("40");
			ParamExt2.setSpecId(TestDataManager.getRandomUUID().toString());
			ParamExt2.setBizCode("100202");
			SubscibeCallbackBean.setParamExt(ParamExt2);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");
			Thread.sleep(2000);
			// 验证第二次扣到0
			Logger.verifyEquals(0, ExpCallService.getCurUserCoin(uid), "金币扣到0");
			List<UserCoinRecord> coinrords = ew.selectUserCoinRecord(SubscibeCallbackBean.getBuyerId(), null, null, null);
			Logger.comment(FormatUtil.beanToGSONString(coinrords));
			UserCoinRecord coinrord = coinrords.get(0);
			Logger.verifyEquals(SubscibeCallbackBean.getParamExt().getSpecId(), coinrord.getOriginalNo(), "验证OriginalNo");
			Logger.verifyEquals(-3, coinrord.getCurCoin(), "验证CurCoin");
			Logger.verifyEquals(-3, coinrord.getTotalCoin(), "验证TotalCoin");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_006() {
		Logger.start(true, "交易服务事件回调成功,部分退款扣除金币后再调用全部退款");
		try {
			// 12-3-3-6
			int uid = 15;
			ExpWapper ew = new ExpWapper();
			ExpCallService.resetCoinAccount(uid);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(TestDataManager.getRandomNum(8));
			SubscibeCallbackBean.setBuyerId(uid);
			SubscibeCallbackBean.setSellerId(111);
			SubscibeCallbackBean.setOrderId("9" + TestDataManager.getRandomNum(8));

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			Thread.sleep(1000);
			ParamExt.setBizCode("100202");
			ParamExt.setPrice("30");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			Thread.sleep(1000);
			ParamExt ParamExt2 = new ParamExt();
			ParamExt2.setBizCode("100202");
			SubscibeCallbackBean.setParamExt(ParamExt2);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean);
			UserCoinRecord coinrord = ew.selectUserCoinRecord(SubscibeCallbackBean.getBuyerId(), null, null, null).get(0);
			Logger.verifyEquals(-6, coinrord.getCurCoin(), "验证CurCoin");
			Logger.verifyEquals(-6, coinrord.getTotalCoin(), "验证TotalCoin");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_007() {
		Logger.start(true, "交易服务事件回调重复调用,确认收货增加金币");
		try {
			// 如果插入了重复数据类的异常返回“ok”给总线
			int uid = 11;
			ExpWapper ew = new ExpWapper();
			ExpCallService.resetCoinAccount(uid);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(TestDataManager.getRandomNum(8));
			SubscibeCallbackBean.setBuyerId(uid);
			SubscibeCallbackBean.setSellerId(111);
			SubscibeCallbackBean.setOrderId(1 + TestDataManager.getRandomNum(8));

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Thread.sleep(1000);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean);
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_008() {
		Logger.start(true, "交易服务事件回调成功,确认收货增加金币,订单虚拟商品不增加");
		try {
			Logger.comment("准备订单数据");
			
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService.placeOrderWithLogisticsType(LogisticsTypeEnum.AutoDelivery);
			Logger.comment("充值");
			String acc=AccountCallServiceV2.getAccountId(Long.valueOf(placeOrderResp.getUserId()).intValue());
			AccountCallServiceV2.resetAccount(acc, new BigDecimal("10000"), new BigDecimal("0"));
			Logger.comment("余额支付");
			Long userId = placeOrderResp.getUserId();
			String orderId=String.valueOf(placeOrderResp.getMainOrderId());
			TradingCallService.payOrder(placeOrderResp.getUserId(), placeOrderResp.getPayableAmount(),
					placeOrderResp.getMainOrderId(), "13");
			
			// Thread.sleep(2000);
			ExpCallService.resetExp(userId.intValue(), 0);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(String.valueOf(placeOrderResp.getMainOrderId()));
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			SubscibeCallbackBean.setSellerId(3383);
			SubscibeCallbackBean.setOrderId(String.valueOf(placeOrderResp.getOrderList().get(0).getOrderId()));

			// SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			// SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice(placeOrderResp.getPayableAmount().toString());
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			 Thread.sleep(2000);
			List<UserCoinRecord> coinrord = ew.selectUserCoinRecord(SubscibeCallbackBean.getBuyerId(), null, SubscibeCallbackBean.getOrderId(), null);
			Logger.comment("UserCoinRecord:" + FormatUtil.beanToGSONString(coinrord));
			Logger.verifyEquals(0, coinrord.size(), "验证不记录此条记录");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_009() {
		Logger.start(true, "交易服务事件,确认收货增加金币老用户5倍");
		try {
			Logger.comment("准备订单数据");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService.placeOrderWithLuxury(false);
			Logger.comment("充值");
			String acc=AccountCallServiceV2.getAccountId(Long.valueOf(placeOrderResp.getUserId()).intValue());
			AccountCallServiceV2.resetAccount(acc, new BigDecimal("10000"), new BigDecimal("0"));
			Logger.comment("余额支付");
			Long userId = placeOrderResp.getUserId();
			String orderId=String.valueOf(placeOrderResp.getMainOrderId());
			TradingCallService.payOrder(placeOrderResp.getUserId(), placeOrderResp.getPayableAmount(),
					placeOrderResp.getMainOrderId(), "13");
			
			Integer sellerId=((Long)placeOrderResp.getOrderList().get(0).getSellerId()).intValue();
			ExpCallService.resetExp(userId.intValue(), 0);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(orderId.toString());
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			
			SubscibeCallbackBean.setSellerId(sellerId);
			SubscibeCallbackBean.setOrderId(orderId.toString());
			// SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			// SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("60");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean, ExpCallService.oldRate);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_010() {
		Logger.start(true, "交易服务事件,确认收货增加金币PSP2倍");
		try {
			Logger.comment("准备订单数据");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService.placeOrderWithLuxury(false);
			Logger.comment("充值");
			String acc=AccountCallServiceV2.getAccountId(Long.valueOf(placeOrderResp.getUserId()).intValue());
			AccountCallServiceV2.resetAccount(acc, new BigDecimal("10000"), new BigDecimal("0"));
			Logger.comment("余额支付");
			Long userId = placeOrderResp.getUserId();
			String orderId=String.valueOf(placeOrderResp.getMainOrderId());
			TradingCallService.payOrder(placeOrderResp.getUserId(), placeOrderResp.getPayableAmount(),
					placeOrderResp.getMainOrderId(), "13");
			Integer sellerId=((Long)placeOrderResp.getOrderList().get(0).getSellerId()).intValue();
			
			ExpCallService.resetCoinAccount(userId.intValue());
			
			Logger.comment("前置数据准备结束");
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(orderId.toString());
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			SubscibeCallbackBean.setSellerId(sellerId);
			SubscibeCallbackBean.setOrderId(orderId.toString());

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean, ExpCallService.pspRate);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_011() {
		Logger.start(true, "交易服务事件回调成功,取消订单扣除金币老客5倍");
		try {
			Logger.comment("准备订单数据");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService.placeOrderWithLuxury(false);
			Logger.comment("充值");
			String acc=AccountCallServiceV2.getAccountId(Long.valueOf(placeOrderResp.getUserId()).intValue());
			AccountCallServiceV2.resetAccount(acc, new BigDecimal("10000"), new BigDecimal("0"));
			Logger.comment("余额支付");
			Long userId = placeOrderResp.getUserId();
			String orderId=String.valueOf(placeOrderResp.getMainOrderId());
			TradingCallService.payOrder(placeOrderResp.getUserId(), placeOrderResp.getPayableAmount(),
					placeOrderResp.getMainOrderId(), "13");
			Integer sellerId=((Long)placeOrderResp.getOrderList().get(0).getSellerId()).intValue();
			ExpCallService.resetCoinAccount(userId.intValue());
			
			ExpCallService.resetExp(userId.intValue(), 0);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(orderId.toString());
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			SubscibeCallbackBean.setSellerId(sellerId);
			SubscibeCallbackBean.setOrderId(orderId.toString());
			// SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			// SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("60");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean, ExpCallService.oldRate);

			Thread.sleep(1000);
			ParamExt.setBizCode("100202");
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean, ExpCallService.oldRate);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_012() {
		Logger.start(true, "交易服务事件回调成功,取消订单扣除金币Psp2倍");
		try {
			Logger.comment("准备订单数据");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService.placeOrderWithLuxury(false);
			Logger.comment("充值");
			String acc=AccountCallServiceV2.getAccountId(Long.valueOf(placeOrderResp.getUserId()).intValue());
			AccountCallServiceV2.resetAccount(acc, new BigDecimal("10000"), new BigDecimal("0"));
			Logger.comment("余额支付");
			Long userId = placeOrderResp.getUserId();
			String orderId=String.valueOf(placeOrderResp.getMainOrderId());
			TradingCallService.payOrder(placeOrderResp.getUserId(), placeOrderResp.getPayableAmount(),
					placeOrderResp.getMainOrderId(), "13");
			Integer sellerId=((Long)placeOrderResp.getOrderList().get(0).getSellerId()).intValue();
			
			Logger.comment("前置数据准备结束");
			Thread.sleep(1000);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(orderId.toString());
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			SubscibeCallbackBean.setSellerId(sellerId);
			SubscibeCallbackBean.setOrderId(orderId.toString());

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			Thread.sleep(1000);
			ParamExt.setBizCode("100202");
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean, ExpCallService.pspRate);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_013() {
		Logger.start(true, "交易服务事件回调成功部分,取消订单扣除金币Psp2倍");
		try {
			Logger.comment("准备订单数据");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService.placeOrderWithLuxury(false);
			Logger.comment("充值");
			String acc=AccountCallServiceV2.getAccountId(Long.valueOf(placeOrderResp.getUserId()).intValue());
			AccountCallServiceV2.resetAccount(acc, new BigDecimal("10000"), new BigDecimal("0"));
			Logger.comment("余额支付");
			Long userId = placeOrderResp.getUserId();
			String orderId=String.valueOf(placeOrderResp.getMainOrderId());
			TradingCallService.payOrder(placeOrderResp.getUserId(), placeOrderResp.getPayableAmount(),
					placeOrderResp.getMainOrderId(), "13");
			Integer sellerId=((Long)placeOrderResp.getOrderList().get(0).getSellerId()).intValue();
			ExpCallService.resetCoinAccount(userId.intValue());
			
			Logger.comment("前置数据准备结束");
			Thread.sleep(1000);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(orderId.toString());
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			SubscibeCallbackBean.setSellerId(sellerId);
			SubscibeCallbackBean.setOrderId(orderId.toString());

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");
			Logger.comment("部分退");
			Thread.sleep(1000);
			ParamExt.setPrice("30");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			ParamExt.setBizCode("100202");
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean, ExpCallService.pspRate);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_014() {
		Logger.start(true, "交易服务事件回调成功部分,取消订单扣除金币老客5倍");
		try {
			Logger.comment("准备订单数据");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService.placeOrderWithLuxury(false);
			Logger.comment("充值");
			String acc=AccountCallServiceV2.getAccountId(Long.valueOf(placeOrderResp.getUserId()).intValue());
			AccountCallServiceV2.resetAccount(acc, new BigDecimal("10000"), new BigDecimal("0"));
			Logger.comment("余额支付");
			Long userId = placeOrderResp.getUserId();
			String orderId=String.valueOf(placeOrderResp.getMainOrderId());
			TradingCallService.payOrder(placeOrderResp.getUserId(), placeOrderResp.getPayableAmount(),
					placeOrderResp.getMainOrderId(), "13");
			Integer sellerId=((Long)placeOrderResp.getOrderList().get(0).getSellerId()).intValue();
			ExpCallService.resetCoinAccount(userId.intValue());
			
			Logger.comment("前置数据准备结束");
			Thread.sleep(1000);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(orderId.toString());
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			SubscibeCallbackBean.setSellerId(sellerId);
			SubscibeCallbackBean.setOrderId(orderId.toString());

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");
			verifyDB(SubscibeCallbackBean, ExpCallService.oldRate);
			Logger.comment("部分退");
			Thread.sleep(1000);
			ParamExt.setPrice("30");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			ParamExt.setBizCode("100202");
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean, ExpCallService.oldRate);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_015() {
		Logger.start(true, "交易服务事件回调成功部分,取消订单退款金额超出原始金额按原始金额计算");
		try {
			Logger.comment("准备订单数据");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService.placeOrderWithLuxury(false);
			Logger.comment("充值");
			String acc=AccountCallServiceV2.getAccountId(Long.valueOf(placeOrderResp.getUserId()).intValue());
			AccountCallServiceV2.resetAccount(acc, new BigDecimal("10000"), new BigDecimal("0"));
			Logger.comment("余额支付");
			Long userId = placeOrderResp.getUserId();
			String orderId=String.valueOf(placeOrderResp.getMainOrderId());
			TradingCallService.payOrder(placeOrderResp.getUserId(), placeOrderResp.getPayableAmount(),
					placeOrderResp.getMainOrderId(), "13");
			Integer sellerId=((Long)placeOrderResp.getOrderList().get(0).getSellerId()).intValue();
			ExpCallService.resetCoinAccount(userId.intValue());
			
			Logger.comment("前置数据准备结束");
			Thread.sleep(1000);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(orderId.toString());
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			SubscibeCallbackBean.setSellerId(sellerId);
			SubscibeCallbackBean.setOrderId(orderId.toString());

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");
			verifyDB(SubscibeCallbackBean, ExpCallService.oldRate);
			Logger.comment("部分退");
			Thread.sleep(1000);
			ParamExt.setPrice("100");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			ParamExt.setBizCode("100202");
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

			verifyDB(SubscibeCallbackBean, ExpCallService.oldRate);
			
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("fail", AddCoinFromTradingCallback.getReturnData(), "验证returndata");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_016() {
		Logger.start(true, "交易服务事件回调成功部分,金币余额不足");
		try {
			Logger.comment("准备订单数据");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService.placeOrderWithLuxury(false);
			Logger.comment("充值");
			String acc=AccountCallServiceV2.getAccountId(Long.valueOf(placeOrderResp.getUserId()).intValue());
			AccountCallServiceV2.resetAccount(acc, new BigDecimal("10000"), new BigDecimal("0"));
			Logger.comment("余额支付");
			Long userId = placeOrderResp.getUserId();
			String orderId=String.valueOf(placeOrderResp.getMainOrderId());
			TradingCallService.payOrder(placeOrderResp.getUserId(), placeOrderResp.getPayableAmount(),
					placeOrderResp.getMainOrderId(), "13");
			Integer sellerId=((Long)placeOrderResp.getOrderList().get(0).getSellerId()).intValue();
			ExpCallService.resetCoinAccount(userId.intValue());
			
			Logger.comment("前置数据准备结束");
			Thread.sleep(1000);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(orderId.toString());
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			SubscibeCallbackBean.setSellerId(sellerId);
			SubscibeCallbackBean.setOrderId(orderId.toString());

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");
			verifyDB(SubscibeCallbackBean, ExpCallService.oldRate);
			Logger.comment("金币消费");
			ExpCallService.accountCoin(userId.intValue(), 1);
			Logger.comment("部分退");
			Thread.sleep(1000);
			ParamExt.setPrice("100");
			ParamExt.setSpecId(TestDataManager.getRandomUUID().toString());
			ParamExt.setBizCode("100202");
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");
			Logger.comment("金币不足时候验证扣光");
			UserCoinRecord coinrord = ew.selectUserCoinRecord(SubscibeCallbackBean.getBuyerId(), null, SubscibeCallbackBean.getOrderId(), null).get(0);
			Logger.verifyEquals(SubscibeCallbackBean.getOrderId(), coinrord.getBizNo(), "验证BizNo");
			Logger.verifyEquals(-1,coinrord.getCurCoin(), "验证CurCoin");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_AddCoinFromTradingCallback_017() {
		Logger.start(true, "全球优选推手端购物不增加金币");
		try {
			Integer userId=107;
			TradingServiceResp placeOrder3 = TradingPlaceHunterOrderCallService
					.placeHunterOrder(1022, userId, 2);

			Long sellerId = placeOrder3.getOrderList().get(0).getSellerId();
			Long orderId = placeOrder3.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder3.getTradingId();
			BigDecimal totalPrice = placeOrder3.getPayableAmount();

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, "13");

			PayGateWayCallService.notifyCall("13", thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(), userId);
			TradingSyncService.getSyncResult(orderId);

			ExpCallService.resetCoinAccount(userId);
			
			Logger.comment("前置数据准备结束");
			Thread.sleep(1000);
			SubscibeCallbackBean.setAppId("autoTest");
			SubscibeCallbackBean.setBusinessType(4);
			SubscibeCallbackBean.setMainOrderId(orderId.toString());
			SubscibeCallbackBean.setBuyerId(userId.intValue());
			SubscibeCallbackBean.setSellerId(sellerId.intValue());
			SubscibeCallbackBean.setOrderId(orderId.toString());

			SubscibeCallbackBean.setYmtCouponCode(TestDataManager.getRandomUUID().toString());
			SubscibeCallbackBean.setSellerCouponCode(TestDataManager.getRandomUUID().toString());

			ParamExt ParamExt = new ParamExt();
			ParamExt.setBizCode("100102");
			ParamExt.setTotalPrice("120");
			ParamExt.setIsShippedByXlobo(false);

			SubscibeCallbackBean.setParamExt(ParamExt);
			AddCoinFromTradingCallback.setData(SubscibeCallbackBean);
			AddCoinFromTradingCallback.callService();
			Logger.verifyEquals("ok", AddCoinFromTradingCallback.getReturnData(), "验证returndata");
			Thread.sleep(3000);
			List<UserCoinRecord> coinrord = ew.selectUserCoinRecord(SubscibeCallbackBean.getBuyerId(), null, SubscibeCallbackBean.getOrderId(), null);
			Logger.verifyEquals(0, coinrord.size(), "验证没有金币记录");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}